////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef __WN_CORE_SYSTEM_H__
#define __WN_CORE_SYSTEM_H__

#include "WNCore/inc/WNPlatform.h"
#include "WNCore/inc/WNTypes.h"

class WNSystem {
public:
    static WN_INLINE WN_VOID Initialize();

    static WN_INLINE WN_UINT8 PhysicalCoreCount();
    static WN_INLINE WN_UINT8 LogicalThreadCount();

    static WN_INLINE WN_UINT64 TotalPhysicalMemory();
    static WN_INLINE WN_UINT64 TotalVirtualMemory();

    static WN_INLINE WN_UINT64 AvailablePhysicalMemory();
    static WN_INLINE WN_UINT64 AvailableVirtualMemory();

    static WN_INLINE WN_BOOL IsHyperThreaded();

    static WN_INLINE WN_BOOL IsLittleEndian();
    static WN_INLINE WN_BOOL IsBigEndian();

    static WN_INLINE WN_BOOL HasFPU();

    // x86 specific feature detection functions. These will all return WN_FALSE if architecture is not x86
    static WN_INLINE WN_BOOL HasCMPXCHG8();
    static WN_INLINE WN_BOOL HasCMPXCHG16();
    static WN_INLINE WN_BOOL HasMMX();
    static WN_INLINE WN_BOOL HasEMMI();
    static WN_INLINE WN_BOOL Has3DNow();
    static WN_INLINE WN_BOOL Has3DNowPlus();
    static WN_INLINE WN_BOOL HasSSE();
    static WN_INLINE WN_BOOL HasSSE2();
    static WN_INLINE WN_BOOL HasSSE3();
    static WN_INLINE WN_BOOL HasSSSE3();
    static WN_INLINE WN_BOOL HasSSE41();
    static WN_INLINE WN_BOOL HasSSE42();
    static WN_INLINE WN_BOOL HasSSE4a();
    static WN_INLINE WN_BOOL HasCVT16();
    static WN_INLINE WN_BOOL HasVEXPrefix();
    static WN_INLINE WN_BOOL HasAES();
    static WN_INLINE WN_BOOL HasCLMUL();
    static WN_INLINE WN_BOOL HasFMA3();
    static WN_INLINE WN_BOOL HasFMA4();
    static WN_INLINE WN_BOOL HasXOP();
    static WN_INLINE WN_BOOL HasAVX();
    static WN_INLINE WN_BOOL HasAVX2();
};

#include "WNCore/inc/WNSystem.inl"

#endif // __WN_CORE_SYSTEM_H__